﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace student
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int age = Convert.ToInt32(txbage.Text);
                decimal score = Convert.ToDecimal(txbscore.Text);
                string sql = string.Format("insert into Students values('{0}',{1},{2})", txbname2.Text, age, score);
                bool jg = DBHelper.ExecuteNonQuery(sql);
                if (jg)
                {
                    MessageBox.Show("添加成功");
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("添加失败");
            }
        }
    }
}
